//
//  NewsListCell.m
//  coba-iOS
//
//  Created by 郭四虎 on 15/12/9.
//  Copyright © 2015年 YouKu. All rights reserved.
//

#import "NewsListCell.h"

@implementation NewsListCell

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
    //self.promoteLb.layer.borderColor = [UIColor colorWithRed:0/255.0 green:122/255.0 blue:255/155.0 alpha:0.5].CGColor;
//    if (IPHONE6){
//        self.titleLb.font = [UIFont systemFontOfSize:16];
//        //self.summaryLb.font = [UIFont systemFontOfSize:12];
//    }else if(IPHONE6P){
//        self.titleLb.font = [UIFont systemFontOfSize:17];
//        //self.summaryLb.font = [UIFont systemFontOfSize:13];
//    }else{
//        self.titleLb.font = [UIFont systemFontOfSize:15];
//        //self.summaryLb.font = [UIFont systemFontOfSize:11];
//    }
}
- (IBAction)upClick:(UIButton *)sender {
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
    font(label, 14);
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor redColor];
    label.center = sender.center;
    label.text = @"+1";
    
    [self.contentView addSubview:label];
    
    [UIView animateWithDuration:0.5 animations:^{
        label.alpha = 0;
        label.y -= 50;
    } completion:^(BOOL finished) {
        
        self.num.text = [NSString stringWithFormat:@"%ld",self.num.text.integerValue +1];
        [label removeFromSuperview];
    }];
}

- (void)showModel:(NewsModel *)model
{
    if ([model.title rangeOfString:@"&quot;"].location !=NSNotFound) {
        
        NSString *str = [model.title stringByReplacingOccurrencesOfString:@"&quot;" withString:@"“"];
        self.titleLb.text = str;
    }else if([model.title rangeOfString:@"&ldquo;"].location !=NSNotFound){
        
        NSString *str = [model.title stringByReplacingOccurrencesOfString:@"&ldquo;" withString:@"“"];
        str = [str stringByReplacingOccurrencesOfString:@"&rdquo;" withString:@"”"];
        
        self.titleLb.text = str;
        
    }else{
        
        self.titleLb.text = model.title;
    }
    //调整title
//    CGSize size = sizeForLabel(self.titleLb,self.titleLb.width);
//    self.titleLb.height = size.height;
    
   
//    if (size.height>32) {
//        self.titleLb.height = 32;
//    }else{
//        self.titleLb.height = size.height;
//    }
    
    if (model.is_read) {
        self.titleLb.textColor = [UIColor lightGrayColor];
    }else{
        self.titleLb.textColor = [UIColor blackColor];
    }
    self.from.x = self.titleLb.x;
    self.from.text = model.author?model.author:@"知行安徽";
    self.num.text = model.num;
//    self.summaryLb.text = model.desc;
//    
//    if (![model.promote_flag integerValue]) {
//        
//        self.promoteLb.hidden = YES;
//    }else{
//        self.promoteLb.hidden = NO;
//    }
    
    NSArray *arr = [model.img_url componentsSeparatedByString:@"#~@"];
    
    //        NSString *str = [NSString stringWithFormat:@"%@%@",CAR_URL,arr[0]];
    NSString *str = arr[0];
    [self.iconIma sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"酷吧LOGO_meitu_1"]];
    
//    if ([ISBUS boolValue]) {
//         NSArray *arr = [model.img_url componentsSeparatedByString:@"#~@"];
//        
////        NSString *str = [NSString stringWithFormat:@"%@%@",CAR_URL,arr[0]];
//        NSString *str = arr[0];
//        [self.iconIma sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"酷吧LOGO_meitu_1"]];
//        
//        
//    }else{
////        NSDate *now = [NSDate date];
////        NSCalendar *calendar = [NSCalendar currentCalendar];
////        NSUInteger uint = NSCalendarUnitYear|NSCalendarUnitMonth;
////        NSDateComponents *component = [calendar components:uint fromDate:now];
//        NSArray *arr = [model.img_url componentsSeparatedByString:@"#~@"];
//        
//        //        NSString *str = [NSString stringWithFormat:@"%@%@",CAR_URL,arr[0]];
//        NSString *str = arr[0];
//        
//        [self.iconIma sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"酷吧LOGO_meitu_1"]];
//        
//    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
